use lutos::secd::vm::Vm;
use lutos::secd::vm::Instruction;
use lutos::secd::vm::Value;

fn main() {
    let mut v=Vm::new();
    //let mut code = vec![Instruction::I_LDC(Box::new(Value::IntVal(100))),Instruction::I_LDC(Box::new(Value::IntVal(20))),Instruction::I_ADD];
    let mut code = vec![Instruction::I_NIL,Instruction::I_LDC(Box::new(Value::IntVal(1))),  Instruction::I_CONS,
                        Instruction::I_LDF(vec![
                            Instruction::I_LD(0,0),
                            Instruction::I_LDC(Box::new(Value::BoolVal(true))),
                            Instruction::I_SEL(Some(vec![Instruction::I_LDC(Box::new(Value::IntVal(2))),Instruction::I_ADD,Instruction::I_JOIN]),None),
                            Instruction::I_RTN
                        ]),
                        Instruction::I_AP];
    v.run(&mut code);
    println!("ret:{:?}",v.stack);
    if v.stack.len()>0{
        println!("ret:{:?}",v.stack.pop());
    }
}
